package com.jiada.shiro.test.serviceImpl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.jiada.shiro.test.dao.PermissionMapper;
import com.jiada.shiro.test.dao.UserMapper;
import com.jiada.shiro.test.model.Permission;
import com.jiada.shiro.test.model.User;
import com.jiada.shiro.test.model.UserExample;
import com.jiada.shiro.test.service.UserService;

@Service
public class UserviceImpl implements UserService {

	@Resource
	UserMapper userMapper;
	@Resource
	PermissionMapper permissionMapper;
	
	@Override
	public List<User> selectByExample(UserExample example) {
		return userMapper.selectByExample(example);
	}

	@Override
	public User selectByUserName(String loginName) {
		
		return userMapper.selectByUserName(loginName);
	}

	@Override
	public List<Permission> getUserPermissions(User user) {
		// TODO Auto-generated method stub
		return permissionMapper.selectByUser(user);
	}

	@Override
	public void saveBook(User user) {
		userMapper.insert(user);
	}

	@Override
	public void deleteBook(User user) {
		userMapper.deleteByPrimaryKey(user.getIduser());
		
	}

	@Override
	public User selectById(User user) {
		return userMapper.selectByPrimaryKey(user.getIduser());
		
	}

}
